package ${controllerPackage};

import com.fow.core.platform.web.rest.RESTController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import ${domainPackage}.${className};
import ${servicePackage}.${className}Service;
import javax.validation.Valid;

@RestController
public class ${className}Controller extends RESTController {

    @Autowired
    private ${className}Service ${tableName}Service;

    @RequestMapping(value="/${tableName}/list", method = RequestMethod.GET)
    public List<${className}> ${tableName}List(){

        return ${tableName}Service.selectList();
    }

    @RequestMapping(value = "/${tableName}/{id}", method = RequestMethod.GET)
    @ResponseBody
    public ${className} getById(@PathVariable String id){

        return (${className})${tableName}Service.selectById(id);
    }

    @RequestMapping(value = "/${tableName}", method = RequestMethod.POST)
    @ResponseBody
    public ${className} add(@Valid @RequestBody ${className} ${tableName}){

        ${tableName}Service.insert(${tableName});
        return ${tableName};
    }

    @RequestMapping(value = "/${tableName}", method = RequestMethod.PUT)
    @ResponseBody
    public ${className} update(@Valid @RequestBody ${className} ${tableName}){

        ${tableName}Service.update(${tableName});
        return ${tableName};
    }

}
